package Control;

import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

import Entity.MsgPackage;
import GUI.PerformanceStageGui;
import GUI.ScreenManager;
/**
 * Controls the instance of Performance  Stage Control
 * This class sends and gets data from the server 
 * and display it on the panel.
 * @author Elad
 *
 */
public class PerformanceStageControl {
	private PerformanceStageGui per_stage_gui;
	private MsgPackage performance;
	private String data;
	
	/**
	 * the constructor
	 */
	public  PerformanceStageControl(){
		per_stage_gui= new PerformanceStageGui(); 
		performance= new MsgPackage();
	}
	/**
	 * 
	 * @return PerformanceStageGui
	 */
	public PerformanceStageGui getPerformanceGui() {
		return per_stage_gui;
	}
	
	/**
	 * 
	 * @param ReqNum to set the request number
	 */
	public void reqANDstageEntered(String ReqNum){
		data= ReqNum;
		
	}
	/**
	 * This method sends the performance leader decision to the server
	 *  The server sends an answer (received from query from database) 
	 *  and the control display it in a message
	 */
	public void performance_Submit_pressed() {
		if((per_stage_gui.getCompletion().isSelected())==false){
			JOptionPane.showMessageDialog(null, "Not all the fileds all the fill", "ERROR", JOptionPane.ERROR_MESSAGE);
		}
		else
		{
			performance.setObject(data);
			performance.setOp_code(OP_CODE.PERFORMANCE_STAGE);
			ScreenManager.getConnection().accept(performance);
			JOptionPane.showMessageDialog(null, "Your stage was updated successfully !!", "", JOptionPane.INFORMATION_MESSAGE);
		}
	}
}
		
		